package com.niit.house.lyl.address;


import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

import java.util.HashMap;

public class AddressPartitioner extends Partitioner<Text,Text> {

    public static HashMap<String,Integer> stateMap= new HashMap<String, Integer>();
    static {
        stateMap.put("成华",0);
        stateMap.put("崇州",1);
        stateMap.put("都江堰",2);
        stateMap.put("高新",3);
        stateMap.put("高新西",4);
    }

    @Override
    public int getPartition(Text key, Text value, int i) {

        Integer code = stateMap.get(value.toString());
        if(code !=null){
            return code;
        }else{
            return 5;
        }


    }
}